#include "share.h"
#include "controler.h"
#include "game.h"
#include "fresh.h"
#include "windows.h"
#include <thread>
#include <mutex>
std::mutex mtx1;

int main() {
    std::thread inputThread(keyboardControl);  // 启动输入线程
    inputThread.detach();  // 让线程自主运行
    while(1) {
        { // 加锁作用域
            std::lock_guard<std::mutex> lock(mtx1);

            switch(mode_now) {
                case 1: {
                    game();
                    break;
                }
                case 2: {
                    fresh(2);
                    while(mode_now == 2)
                    {
                        Sleep(100); 
                    }
                    break; 
                }
                case 3: {
                    fresh(3);
                    while(mode_now == 3)
                    {
                        Sleep(100); 
                    }
                    clearConsole();
                    break; 
                }
                case 4: {
                    fresh(4);
                    while(mode_now == 4)
                    {
                        Sleep(100);
                    }
                    clearConsole();
                    break; 
                }
                case 5: {
                    fresh(5);
                    while(mode_now == 5)
                    {
                        Sleep(100);
                    }
                    clearConsole();
                    break; 
                }                
            }
        }

    }
}